/*
 * TOUCH.c
 *
 * Created: 18.09.2012 08:53:02
 *  Author: mariuvi
 */ 
/*
 * SLIDER.c
 *
 * Created: 12.09.2012 19:04:25
 *  Author: mariuvi
 */
#include "USART.h"
#include "SLIDER.h"
#include "ADC.h"
#include <util/delay.h>
#include <avr/io.h>

#define SLIDER_1_CH 1
#define MID 128
 
int SLIDER_read()
{
	int SLIDER_position;
	
	//Reads the sliders position	
	SLIDER_position = (int)ADC_read(SLIDER_1_CH);
	SLIDER_position = 100*(SLIDER_position - MID)/(MID);
	
	return SLIDER_position;
}

void SLIDER_buttons_init()
{
	DDRB |= (0 << DDB0) | (0 << DDB1);	
}

int SLIDER_button_read(int button)
{
	if(button == 1)
	{
		return (PINB & (1 << PINB0));	
	}
	else if(button == 2)
	{
		return (PINB & (1 << PINB1));
	}
}

